Skip to content

feat(browserContext): support maximized viewport - #42286

Open
Devin Rousso (dcrousso) wants to merge 1 commit into
microsoft:mainfrom
dcrousso:fix-1086
Open

feat(browserContext): support maximized viewport#42286
Devin Rousso (dcrousso) wants to merge 1 commit into
microsoft:mainfrom
dcrousso:fix-1086

Conversation

@dcrousso

@dcrousso Devin Rousso (dcrousso) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

allow viewport: 'maximized' to maximize native browser windows without a default emulated viewport

keep native maximization independent of browser fullscreen and the web Fullscreen API

preserve the maximized outer window when Page.setViewportSize() enables viewport emulation

fixes #1086

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 CI is clear — the one failure is a pre-existing Windows flake

Hi, I'm the Playwright bot and I took a look at the failing CI on this PR. The single red test — playwright.trace.spec.ts:434 › should retain traces for interrupted tests on [playwright-test] @windows-latest-node22 — is a known Windows-only flake, unrelated to this PR's windowState change. Nothing here looks caused by the PR.

Details

This PR adds a windowState browser-context option (touching browserContext.ts, crPage.ts, ffBrowser.ts, wkPage.ts, protocol, and headful.spec.ts). It doesn't go near the test runner's trace-retention path that this test exercises.

Pre-existing flake / infra

  • [playwright-test] › playwright.trace.spec.ts:434 › should retain traces for interrupted tests — flake. In the aggregated CI results it flips verdict only on windows-latest-node22: failed 4 of 658 runs there (~0.6%), passed the other 654, and never fails on any other bot (0 failures across all Linux/macOS runners). The 4 failures are on SHAs this PR can't be responsible for — main (43a91219, 40372734) and PRs feat(test-runner): annotate serial suites for custom sharding #42164 (4e5071fd) and fix(chromium): keep closing the target so page.close() cannot hang on a navigation commit #41912 (21e8d31e), none of which touch windowState. Every failure carries the same signature (expect(received).toBe(expected) / Expected: 1, Received: 0 — a missing trace on a timing-sensitive interrupted-test check), which is the classic shape of this flake. Windows-only, on unrelated SHAs → not PR-specific.

The other 22 tests in the report are within-run flakes (rescued on retry), so there's nothing to triage there.

Triaged by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🟢 CI is clear — both failures are pre-existing flakes

Hi, I'm the Playwright bot and I took a look at the failing CI on this PR. Two tests are red across the latest reports — mcp/config.spec.ts:203 › --sandbox enables the sandbox ([chrome]) and playwright.trace.spec.ts:434 › should retain traces for interrupted tests ([playwright-test] @windows-latest-node22). Both are known flakes that fail on SHAs this PR can't be responsible for. Nothing here looks caused by the windowState change.

Details

This PR adds a windowState browser-context option (browserContext.ts, crPage.ts, ffBrowser.ts, wkPage.ts, protocol, docs, and headful.spec.ts). It doesn't touch the MCP config/sandbox flow or the test runner's trace-retention path, so neither red test exercises changed code.

Pre-existing flake / infra

The remaining tests in the reports are within-run flakes (rescued on retry), so there's nothing to triage there.

Triaged by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

await context.close();
});

it('should keep native window maximized when resizing viewport', async ({ browser, browserName }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean for the user? How does it look?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

page.setViewportSize() sets a fixed inner viewport without resizing the maximized native window leaving unused space around the 567x345 page

Comment thread tests/library/headful.spec.ts Outdated
await context.close();
});

it('should open popups in maximized windows', async ({ browser, browserName, server }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to also understand the expected behavior of things like "shift+click" that opens a new window, or window.open('', '_blank', 'left=100,top=100,width=320,height=320').

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maximizing should override popup geometry for shift-click and explicitly sized window.open()

i've added tests for both

allow `viewport: 'maximized'` to maximize native browser windows without a default emulated viewport

keep native maximization independent of browser fullscreen and the web Fullscreen API

preserve the maximized outer window when `Page.setViewportSize()` enables viewport emulation
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

8 flaky ⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/browsercontext-page-event.spec.ts:173 › should work with Ctrl-clicking `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:356 › screencast › should work for popups `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-goto.spec.ts:90 › should work with Cross-Origin-Opener-Policy `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-page] › page/page-leaks.spec.ts:164 › waitFor should not leak `@webkit-ubuntu-22.04-node20`

51356 passed, 1287 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

8327 passed, 1371 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] create context in fullscreen mode

2 participants